/**@FILE:ApplyReturnServiceImpl.java
 * @AUTHOR:qingsheng.zheng
 * @DATE:2015-2-10 下午10:59:46*/
package com.xf.toy.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xf.toy.bean.ApplyReturn;
import com.xf.toy.bean.ApplyReturnExample;
import com.xf.toy.bean.ApplyReturnExample.Criteria;
import com.xf.toy.dao.ApplyReturnMapper;
import com.xf.toy.dao.page.Pagination;
import com.xf.toy.service.ApplyReturnService;

/*******************************************
 * @COMPANY:alibaba
 * @CLASS:ApplyReturnServiceImpl
 * @DESCRIPTION:	
 * @AUTHOR:qingsheng.zheng
 * @VERSION:v1.0
 * @DATE:2015-2-10 下午10:59:46
 *******************************************/
@Service("applyReturnService")
public class ApplyReturnServiceImpl implements ApplyReturnService{
	@Resource
	private ApplyReturnMapper applyMapper;

	@Override
	public List<ApplyReturn> selectApplyList(ApplyReturn apply,Pagination page) {
		ApplyReturnExample example=new ApplyReturnExample();
		if (page != null) {
			example.setLimitStart(page.getStart());
			example.setLimitEnd(page.getPageSize());
		}
		Criteria criteria= example.createCriteria();
		if(apply.getStatus()!=null)
			criteria.andStatusEqualTo(apply.getStatus()); 
		page.setTotalcount(applyMapper.countByExample(example));
		return applyMapper.selectByExample(example);
	}

	@Override
	public void updateStatusByOrderid(Long orderid, String status) {
		ApplyReturnExample apply=new ApplyReturnExample();
		Criteria criteria=apply.createCriteria();
		criteria.andOrderIdEqualTo(orderid);
		ApplyReturn applyReturn=new ApplyReturn();
		applyReturn.setStatus(status);
		applyMapper.updateByExampleSelective(applyReturn, apply);
		
	}

	@Override
	public void applyReturn(ApplyReturn apply) {
		applyMapper.insert(apply);
		
	}
	
	

}

